#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
float func1(float x)
{
	return 1 + x * x;
}
float func2(float x)
{
	return x / (1 + x * x);
}
float result(float(*f)(float), float a, float b, int n)
{
	float h = (b - a) / n;
	float sum = f(a) + f(a + h);
	for (int i = 1; i < n; i++)
	{
		sum += f(a + i * h) + f(a + (i + 1) * h);
	}
	return (sum * h)/2.0;
}
int main()
{
	int a = 0;
	int b = 1;
	int n = 100;
	float y1=result(func1,a,b,n);
	float y2=result(func2,a,b,n);
	printf("y1=%f\n", y1);
	printf("y2=%f\n", y2);
	return 0;
}